#include "GobangDoc.h"
#include "calculate.h"

void calculate(BoardState* pattern,int* prefix,int patternLen){
	const int len=patternLen;
	int mNum=0;
	prefix[0]=0;

	for(int i=1;i<len;++i){
		while(mNum>0 && pattern[mNum+1]!=pattern[i]){
			mNum=prefix[mNum];
		}

		if(pattern[mNum]==pattern[i]){
			++mNum;
		}

		prefix[i]=mNum;
	}
}
